package io.renren.modules.erp.service;

import com.baomidou.mybatisplus.extension.service.IService;
import io.renren.common.utils.PageUtils;
import io.renren.modules.erp.entity.Material;
import io.renren.modules.erp.entity.MaterialVo4Unit;
import jxl.Sheet;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

public interface MaterialService extends IService<Material> {

    Material getMaterial(long id)throws Exception ;

    List<Material> getMaterialListByIds(String ids)throws Exception ;

    List<Material> getMaterial() throws Exception;

    PageUtils select(String barCode, String name, String standard, String model, String categoryIds, String mpList, int currPage, int  pageSize,String beginstock,String endstock,String beginavailableStock,String endavailableStock)
            throws Exception;
    Long countMaterial(String barCode, String name, String standard, String model, String categoryIds,String mpList)throws Exception ;

    int insertMaterial(String beanJson, HttpServletRequest request,String userName)throws Exception ;

    int updateMaterial(String beanJson, Long id, HttpServletRequest request,String userName) throws Exception;

    int deleteMaterial(Long id, HttpServletRequest request)throws Exception ;

    int batchDeleteMaterial(String ids, HttpServletRequest request)throws Exception ;

    int checkIsNameExist(Long id, String name)throws Exception ;

    int checkIsExist(Long id, String name, String model, String color, String standard, String mfrs,
                     String otherField1, String otherField2, String otherField3, String unit, Long unitId)throws Exception ;
    int batchSetEnable(Boolean enabled, String materialIDs)throws Exception ;
    String findUnitName(Long mId)throws Exception;

    List<MaterialVo4Unit> findById(Long id)throws Exception;
    List<MaterialVo4Unit> findByIdWithBarCode(Long meId)throws Exception;
    List<MaterialVo4Unit> findBySelectWithBarCode(String q,Integer offset, Integer rows)throws Exception;
    int findBySelectWithBarCodeCount(String q)throws Exception;
    List<MaterialVo4Unit> findByAll(String name, String model, String categoryIds)throws Exception ;

    void importExcel(Sheet src,String userName) throws Exception ;
    void insertStockByMaterialAndDepot(Long depotId, Long mId, BigDecimal stock);
    List<Material> getMaterialEnableSerialNumberList(Map<String, Object> parameterMap)throws Exception ;
    Long getMaterialEnableSerialNumberCount(Map<String, Object> parameterMap)throws Exception ;
    int batchDeleteMaterialByIds(String ids,Long userId) throws Exception;

    int batchDeleteMaterialByIdsNormal(String ids,Long userId) throws Exception;
    BigDecimal parseBigDecimalEx(String str) throws Exception;
    BigDecimal parsePrice(String price, String ratio) throws Exception;
    BigDecimal getInitStock(Long materialId, Long depotId) ;
    BigDecimal getInitStockByMid(Long depotId, Long materialId) ;
    List<MaterialVo4Unit> getMaterialByMeId(Long meId) ;
    String getMaxBarCode() ;
    List<String> getMaterialNameList() ;
}
